/*
 * ListOperatorExpression.java
 *
 * Created on March 1, 2007, 10:17 PM
 *
 * (C) R. Alexander Milowski alex@milowski.com
 */

package com.smallx.xpath.parser;

/**
 *
 * @author R. Alexander Milowski
 */
public class PairExpression implements Expression {
   
   Operator operator;
   Expression first;
   Expression second;
   /** Creates a new instance of ListOperatorExpression */
   public PairExpression(Operator operator,Expression first,Expression second) {
      this.operator = operator;
      this.first = first;
      this.second = second;
   }
   
   public Expression getFirst() {
      return first;
   }
   
   public Operator getOperator() {
      return operator;
   }
   
   public Expression followFirst() {
      if (first instanceof PairExpression) {
         return ((PairExpression)first).followFirst();
      }
      return first;
   }
   
   public Expression getSecond() {
      return second;
   }
   
   public Expression followSecond() {
      if (second instanceof PairExpression) {
         return ((PairExpression)second).followSecond();
      }
      return second;
   }
   
   public String toString() {
      return "("+operator+" "+first.toString()+" "+second.toString()+" )";
   }
}
